package com.gaoxiang.Day6API.Repository;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.gaoxiang.Day6API.entity.Company;

@Repository
public class CompanySerImpl implements CompanySer {
	@Autowired 
	private JdbcTemplate db;

	@Override
	public Collection<Company> Query() {
		return db.query("SELECT * FROM `staff21732`", new BeanPropertyRowMapper<Company>(Company.class));
	}

	@Override
	public void Insert(Company company) {
		// TODO Auto-generated method stub
		db.update("INSERT INTO staff21732 (name,company,job,cdate) values (?,?,?,?)",company.getName(),company.getCompany(),company.getJob(),company.getCdate());
	}

	@Override
	public void Update(Company company) {
		// TODO Auto-generated method stub
		db.update("update staff21732 set name = ?,company=?,job=?,cdate=? where company = ?",company.getName(),company.getCompany(),company.getJob(),company.getCdate(),company.getCompany());
	}

	@Override
	public void Delete(String company) {
		// TODO Auto-generated method stub
		db.update("delete from staff21732 where company = ?", company);
	}
	
}
